//
//  YLRequestTool.swift
//  test
//
//  Created by lyl on 2020/7/8.
//  Copyright © 2020年 lyl. All rights reserved.
//

import UIKit

class YLRequestTool: NSObject {
    //MARK: - 下载文件
    class func download(urlStr: String,success: @escaping ((_ result: Data?) -> ()),failure: @escaping ((_ error: Error) -> ())) {
        let url = URL(string: urlStr)
        var request = URLRequest(url: url!)
        request.timeoutInterval = 20
        request.httpMethod = "GET"
        MyLog(getToken())
        let session = URLSession.shared
        let dataTask = session.dataTask(with: request) { (data, respond, error) in
            MyLog(data)
            if error == nil {
                success(data)
            }else {
                if error != nil { failure(error!) }
            }
        }
        dataTask.resume()
    }
    
}
